<template>
    <div class="">
        <!-- 条件筛选-----查询 -->
        <el-form :inline="true">
            <div style="display: flex; justify-content: space-between;">
                <div>
                    <el-form-item>
                        <el-input v-model="key" clearable placeholder="请输入查询内容" style="width: 500px;" />
                    </el-form-item>
                    <el-form-item>
                        <el-button type="primary" @click="init">查询</el-button>
                    </el-form-item>
                </div>
                <div />
            </div>
        </el-form>
        <!-- 列表数据 -->
        <el-table v-loading="listLoading" :data="tableData" border style="width: 100%">
            <el-table-column prop="userid" label="用户ID" align="center" />
            <el-table-column prop="userAddress" label="用户地址" align="center" />
            <el-table-column prop="selfamount" label="个人业绩USDT" align="center" />
            <el-table-column prop="teamamount" label="团队业绩USDT" align="center" />
            <el-table-column prop="totaljc" label="级差奖" align="center" />
            <el-table-column prop="totalzt" label="直推奖" align="center" />
            <el-table-column prop="totalup" label="上线奖" align="center" />
            <el-table-column prop="totaldown" label="下线奖" align="center" />
            <el-table-column prop="totalleft" label="左点奖励" align="center" />
            <el-table-column prop="totalright" label="右点奖励" align="center" />
            <el-table-column prop="teamusercount" label="团队人数" align="center" />
            <el-table-column prop="azparent" label="安置上级" align="center" />
        </el-table>
        <!-- 分页 -->
        <div class="block " style="padding-top: 20px;">
            <el-pagination background :current-page="PageIndex" :page-sizes="[10, 20, 30, 40]" :page-size="pageSize"
                layout="total, sizes, prev, pager, next, jumper" :total="totalCount"
                @size-change="idx => { pageSize = idx }" @current-change="idx => { PageIndex = idx }" />
        </div>

    </div>
</template>
  
<script>
import { teamtotal } from '@/api/users.js'
export default {
    name: 'Name',
    data() {
        return {
            // 筛选参数
            key: '',

            // 列表相关
            listLoading: false,
            tableData: [],
            totalCount: 0,
            PageIndex: 1,
            pageSize: 10,
        }
    },
    watch: {
        PageIndex(val) {
            this.getData()
        },
        pageSize(val) {
            this.getData()
        }
    },
    created() {
        this.key = this.$route.query.useraddress || ''
        console.log(this.key);
    },
    async mounted() {
        this.getData()
    },
    methods: {
        /** 刷新加载 */
        init() {
            this.PageIndex = 1
            this.getData()
        },
        // ////////////////////////////////////////// 数据请求 /////////////////////////////////////////////
        /** 主列表 */
        async getData() {
            this.listLoading = true
            const { list, pageIndex, totalCount } = await teamtotal({
                key: this.key,
                PageIndex: this.PageIndex,
                PageSize: this.pageSize
            })
            this.listLoading = false
            if (list) {
                this.totalCount = totalCount
                this.tableData = list
            }
        },
    }
}
</script>
  
<style lang="scss">
.el-table .warning-row {
    background: oldlace;
}
</style>
  